import { UP_DOWN_SHELVES_OPTIONS, IMAGE_TEXT_STATE_OPTIONS } from '@/constants/commodity';
import { getUserInfoListService, getDepartmentsService } from '@/api/usercenter';
import { queryFinalCategoryService, getAllBrandListService } from '@/api/commodity/common';
import { list2Obj } from '@/utils/bizUtils';

export const FORM_ITEM_LIST = [
  {
    prop: 'categoryUuid',
    label: '四级类名称',
    type: 'select',
    remote: true,
    remoteMethod: queryFinalCategoryService,
    paramKey: 'key',
    optionKeys: { valueKey: 'categoryUuid', labelKey: 'categoryName' },
    searchType: 'EQ'
  },
  {
    prop: 'skuNo',
    label: 'SKU编码',
    type: 'input',
    searchType: 'EQ'
  },
  {
    prop: 'brandUuid',
    label: '品牌',
    type: 'select',
    remote: true,
    remoteMethod: getAllBrandListService,
    paramKey: 'brandName',
    optionKeys: { valueKey: 'brandUuid', labelKey: 'brandName' },
    searchType: 'EQ'
  },
  {
    prop: 'productName',
    label: '商品名称',
    type: 'input'
  },
  {
    prop: 'createOper',
    label: '创建人',
    type: 'select',
    remote: true,
    remoteMethod: getUserInfoListService,
    paramKey: 'userName',
    optionKeys: { valueKey: 'userIdStr', labelKey: 'userName', codeKey: 'jobNumber' },
    searchType: 'EQ'
  },
  {
    prop: 'operDeptUuid',
    label: '创建人部门',
    type: 'select',
    remote: true,
    remoteMethod: getDepartmentsService,
    paramKey: 'departmentName',
    optionKeys: { valueKey: 'departmentId', labelKey: 'departmentName' },
    searchType: 'EQ'
  },
  // createOpeTimeStart, createOpeTimeEnd
  {
    prop: 'createOpeTime',
    label: '创建时间',
    type: 'datePicker',
    datePickerType: 'daterange',
    valueFormat: 'yyyy-MM-dd',
    searchType: 'EQ'
  },
  // expectOffTimeStart expectOffTimeEnd
  {
    prop: 'expectOffTime',
    label: '预计下架时间',
    type: 'datePicker',
    datePickerType: 'daterange',
    valueFormat: 'yyyy-MM-dd',
    searchType: 'EQ'
  },
  {
    prop: 'upState',
    label: '上下架状态',
    type: 'select',
    options: UP_DOWN_SHELVES_OPTIONS,
    defaultVal: '1',
    searchType: 'EQ'
  },
  {
    prop: 'imageStatus',
    label: '图文完善状态',
    type: 'select',
    clearable: true,
    options: IMAGE_TEXT_STATE_OPTIONS,
    searchType: 'EQ'
  },
  {
    prop: 'recordNo',
    label: '单据号',
    type: 'input',
    searchType: 'EQ'
  },
]
export const TABLE_COLUMNS = [
  {
    title: '单据号',
    key: 'recordNo',
  },
  {
    title: '创建人',
    key: 'createOpeName',
    width: 80
  },
  {
    title: '创建时间',
    key: 'createOpeTime',
  },
  {
    title: '部门',
    key: 'operDeptName',
    width: 90
  },
  {
    title: '公司',
    key: 'hrCompanyName',
  },
  {
    title: '提交状态',
    key: 'productAddStateStr',
  },
  {
    title: '上下架状态',
    key: 'upStateStr',
  },
  {
    title: '四级类代码',
    key: 'categoryNo',
  },
  {
    title: '四级类名称',
    key: 'categoryName',
  },
  {
    title: 'SKU编码',
    key: 'skuNo',
    width: 90
  },
  {
    title: '品牌',
    key: 'brandName',
  },
  {
    title: '其它品牌',
    key: 'otherBrandName',
  },
  {
    title: '商品名称',
    key: 'productName',
  },
  {
    title: '规格',
    key: 'specModel',
  },
  {
    title: '计量单位',
    key: 'unitName',
    width: 80
  },
  {
    title: '成本价',
    key: 'costPrice',
    width: 80
  },
  {
    title: '折扣价',
    key: 'salePrice',
    width: 80
  },
  {
    title: '售价',
    key: 'sellPrice',
    width: 100
  },
  {
    title: '售卖平台',
    key: 'salePlatStr',
    width: 80
  },
  {
    title: '销售区域',
    key: 'saleAreaStr',
    width: 80
  },
  {
    title: '预计下架时间',
    key: 'expectOffTime',
  },
  {
    title: '图文完善状态',
    key: 'imageStatus',
  },
  {
    title: '来源',
    key: 'sourceStr',
    width: 80
  },
]
// 下架类型
export const OFFTIME_TYPE_OPTIONS = [
  { label: '到期下架', value: '1' },
  { label: '永不下架', value: '2' },
  // { label: '售完下架', value: 3 },
]
// 是否自定义商品名称
export const PRODUCT_NAME_TYPE = [
  { label: '否', value: '1' },
  { label: '是', value: '2' },
]

// 查看线索商品
export const VIEW_TABLE_COLUMN = [
  {
    key: 'skuNo',
    title: '商品代码',
  },
  {
    key: 'categoryName',
    title: '末级分类',
  },
  {
    key: 'classificationName',
    title: '归类名称',
  },
  {
    key: 'taxRate',
    title: '销售税率',
  },
  {
    key: 'brandName',
    title: '品牌',
  },
  {
    key: 'seriesUuid',
    title: '系列',
  },
  {
    key: 'productNameType',
    title: '是否自定义商品名称',
    formatter: (row, columns, cellValue) => {
      return list2Obj(PRODUCT_NAME_TYPE)[cellValue];
    }
  },
  {
    key: 'productName',
    title: '商品名称',
  },
  {
    key: 'material',
    title: '材质',
  },
  {
    key: 'mainCategoryName',
    title: '主品类名称',
  },
  {
    key: 'specModel',
    title: '规格',
  },
  {
    key: 'unitName',
    title: '计量单位',
  },
  {
    key: 'edge1',
    title: '最长边(cm)',
  },
  {
    key: 'edge2',
    title: '次长边(cm)',
  },
  {
    key: 'edge3',
    title: '最短边(cm)',
  },
  {
    key: 'volume',
    title: '体积(m3)',
  },
  {
    key: 'weight',
    title: '重量(kg)',
  },
  {
    key: 'canCustom',
    title: '是否定制',
  },
  {
    key: 'note',
    title: '特殊要求说明',
  },
  {
    key: 'purchasePrice',
    title: '进价',
  },
  {
    key: 'costPrice',
    title: '成本价',
  },
  {
    key: 'sellPrice',
    title: '售价',
  },
  {
    key: 'salePlatNames',
    title: '售卖平台',
  },
  {
    key: 'saleAreaStr',
    title: '销售区域',
  },
  {
    key: 'saleMin',
    title: '最小起售量',
  },
  {
    key: 'saleResType',
    title: '销售限制类型',
  },
  {
    key: 'arrivalPeriod',
    title: '到货周期',
  },
  {
    key: 'createOpeName',
    title: '创建人',
  },
  {
    key: 'opeTime',
    title: '创建时间',
  },
  {
    key: 'operDeptName',
    title: '创建人部门',
  },
]
